<%@page import="com.sun.jndi.url.dns.dnsURLContext"%>
<%@page import="com.netistate.pojo.Doc"%>
<%@page import="com.netistate.pojo.ProjectServices"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="com.netistate.pojo.User"%>
<%@page import="com.netistate.pojo.Project"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>项目页面</title>
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/default.css" />
    <script type="text/javascript"  src="${pageContext.request.contextPath}/js/jquery-min.js"></script> 
    <script type="text/javascript"  src="${pageContext.request.contextPath}/js/common.js"></script>
    <script type="text/javascript"  src="${pageContext.request.contextPath}/js/table.js"></script>
    <script type="text/javascript"  src="${pageContext.request.contextPath}/plugin/msgbox/msgbox.js"></script>
    <script type="text/javascript"  src="${pageContext.request.contextPath}/jsp/project/project.js"></script>
    <script type="text/javascript"  src="${pageContext.request.contextPath}/plugin/calendar/Calendar.js"></script>
    <style type="text/css">
		.overTd {table-layout:fixed}
		.overTd td{text-overflow:ellipsis;overflow:hidden;white-space:nowrap;padding:0px}
    </style>
  </head>
  <body>
   <% String id = (String)request.getSession().getAttribute("projectid");
   	  Project p = (Project)request.getSession().getAttribute("selectProject");
   %>
   
   		
   		<div id="xtab">
			<a id="rightDiv0_tab" href="#" class='homelink curren' onclick=""><span style="cursor:pointer;">服务记录表</span></a>
			<a id="rightDiv1_tab" href="#" class='homelink' onclick="lookTechNote(<%=id%>)"><span style="cursor: pointer;">技术备忘录</span></a>
			<a id="rightDiv1_tab" href="#" class='homelink' onclick="lookClient(<%=id%>)"><span style="cursor: pointer;">客户信息表</span></a>
			<a id="rightDiv1_tab" href="#" class='homelink' onclick="lookDoc(<%=id%>)"><span style="cursor: pointer;">文档列表</span></a>
		</div>
   		
   		<div class="toolbar" >
   			<a href="#" class='buttonlink txbtip' style="font-size:14pt;font-family:微软雅黑;display:inline;color:red" title='当前项目'>当前位置：<%=p.getProjectName() %>→项目服务表</a>
   				<img width='16' height='16' src='${pageContext.request.contextPath}/images/common/elbow-line.gif'/>
		    <a href="#" class='buttonlink txbtip' title='添加项目服务表' onclick="addSale(<%=id%>)"><img width='16' height='16' src='${pageContext.request.contextPath}/images/common/plus.png'/>添加项目服务表</a>
		    	<img width='16' height='16' src='${pageContext.request.contextPath}/images/common/elbow-line.gif'/><img width='16' height='16' src='${pageContext.request.contextPath}/images/common/elbow-line.gif'/>
		    <a href="#" id="queryProjectButton" title='项目服务表查询' class='buttonlink txbtip' onclick="notHiddenDiv()" ><img width='16' height='16' src='${pageContext.request.contextPath}/images/common/flag_green.png'/>项目服务表查询</a>
		    <%-- <a href="#" class='buttonlink txbtip' title='添加技术备忘录' onclick="addTechNote(<%=id%>)"><img width='16' height='16' src='${pageContext.request.contextPath}/images/common/plus_orange.png'/>添加技术备忘录</a> --%>
		    	<img width='16' height='16' src='${pageContext.request.contextPath}/images/common/elbow-line.gif'/><img width='16' height='16' src='${pageContext.request.contextPath}/images/common/elbow-line.gif'/>
		    <%-- <a href="find_all_workNote.action?pid=<%=id%>" target="_blank" class='buttonlink txbtip' title='查询所有工作记录' onclick="findAllWorkNote(<%=id%>)"><img width='16' height='16' src='${pageContext.request.contextPath}/images/common/search.png'/>查询所有工作记录</a>	
		    <div style="float:right">  
			    <a id="selectTechNote" href="#" class='buttonlink txbtip' title='技术备忘录' onclick="lookTechNote(<%=id%>)"><img width='16' height='16' src='${pageContext.request.contextPath}/images/common/search.png'/>技术备忘录</a>
	       		<a href="#" class='buttonlink txbtip' title='客户信息表' onclick="lookClient(<%=id%>)"><img width='16' height='16' src='${pageContext.request.contextPath}/images/common/safari.png'/>客户信息表</a>
	       		<a href="#" class='' title='' onclick="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a>
       		</div>  --%>
		</div>
		
		
		<div id="queryProjectService" name="queryProjectService" class="toolbar" style="display:none;overflow:hidden;">
		    <form id="queryProjectServiceByCondition" name="projectQuery_condition" action="findAllProjectServices.action" method="post">
		    	<input type="hidden" name="pid" value="<%=id%>"/>
		    </form>
	        <table>
	           <tr>
	           		<form id="findProjectServiceType" target="_blank" action="findProjectServiceTypeByServiceType.action" method="post">
		                <td class="td_title" title="项目服务类型">按项目服务类型查询：</td>
		                <td class="td_title">
		                	<input type="hidden" name="pid" value="<%=id%>"/>
		                    <select id="projectServiceType" name="projectServiceType">
								<option title="所有类型" value="所有">所有类型</option>
								<option title="现场售后服务" value="现场售后服务">现场售后服务</option>
								<option title="现场实施服务" value="现场实施服务">现场实施服务</option>
								<option title="现场售前测试(POC)" value="现场售前测试(POC)">现场售前测试(POC)</option>
								<!-- <option title="系统升级服务" value="系统升级服务">系统升级服务</option> -->
								<option title="售前交流" value="售前交流">售前交流</option>
								<option title="会议纪要" value="会议纪要">会议纪要</option>
								<option title="文档编写" value="文档编写">文档编写</option>
								<option title="客户拜访" value="客户拜访">客户拜访</option>
		                    </select>
		                </td>
		                <td>
							<img alt="" src="${pageContext.request.contextPath}/images/common/search.png"><input type="submit" value="查看"/></img>
						</td>
	                </form>
	                <form id="findInfoType" target="_blank" action="findInfoByinfoType.action" method="post">
		                <td>
		                	<img width='16' height='16' src='${pageContext.request.contextPath}/images/common/elbow-line.gif'/><img width='16' height='16' src='${pageContext.request.contextPath}/images/common/elbow-line.gif'/>
		                </td>
	                	<td title="信息类型">按信息类型查询：</td>
		                <td>
		                	<input type="hidden" name="pid" value="<%=id%>"/>
		                    <select id="infoType" name="infoType">
		                           <option value="所有">所有内容</option>
			                       <option value="预期目标">预期目标</option>
								   <option value="工作内容记录">客工作内容记录</option>
								   <option value="客户关注点">客户关注点</option>
								   <option value="下一步计划">下一步计划</option>
								   <option value="交流信息纪要">交流信息纪要</option>
								   <option value="遗留问题">遗留问题</option>
								   <option value="看法和建议">看法和建议</option>
								   <option value="其他备注">其他备注</option>
								   <option value="客户环境调查">客户环境调查</option>
								   <option value="文档说明">文档说明</option>
								   <option value="竞争对手动态">竞争对手动态</option>
								   <option value="修改升级后的产品信息">修改升级后的产品信息</option>
								   <option value="关联显示产品信息">关联显示产品信息</option>
								   <option value="对方接收人">对方接收人</option>
								   <option value="预算及时间预期">预算及时间预期</option>
		                    </select>
		                </td>
		                <td>
							<img alt="" src="${pageContext.request.contextPath}/images/common/search.png"><input type="submit" value="查看"/></img>
						</td>
	                </form>
	                <td>
	                	<img width='16' height='16' src='${pageContext.request.contextPath}/images/common/elbow-line.gif'/><img width='16' height='16' src='${pageContext.request.contextPath}/images/common/elbow-line.gif'/>
	                </td>
	                <td>
	                	<a href="find_all_workNote.action?pid=<%=id%>" target="_blank" class='buttonlink txbtip' title='查询所有工作记录' onclick="<%-- findAllWorkNote(<%=id%>) --%>"><img width='16' height='16' src='${pageContext.request.contextPath}/images/common/search.png'/>查询所有工作记录</a>
	                </td>
	                <td>
	                	<img width='16' height='16' src='${pageContext.request.contextPath}/images/common/elbow-line.gif'/><img width='16' height='16' src='${pageContext.request.contextPath}/images/common/elbow-line.gif'/>
	                </td>
					<td>
						<a href="javascript:;" class='txbtip' title='查看相关产品及信息' onclick="lookProductDemoMsg(<%=id%>)"><img width='16' height='16' src='${pageContext.request.contextPath}/images/common/search.png'/>查看相关产品及Demo信息</a>
					</td>
					
				</tr>
	        </table>
		    
		</div>
		
   		<%-- <iframe id="changePage" name="changePage" src="${pageContext.request.contextPath}/jsp/project/project_sale.jsp" width="100%" height="500px;"></iframe> --%>
   		
   		<div id="rcon_onepage" style="width:100%;height:95%; overflow-y:scroll; border:1px solid;" >
			<table id="dArticleList" width="100%" border="0" cellpadding="0" cellspacing="1"  class="resizable overTd">
				<thead>
					<tr class="fixHead">
						<td  class="td1" style="cursor:pointer" width="15%">服务记录名称</td>
						<td  class="td1" style="cursor:pointer" width="15%">支持日期</td>
						<td  class="td1" style="cursor:pointer" width="15%">服务类型</td>
						<td  class="td1" style="cursor:pointer" width="8%">服务工程师</td>
						<td  class="td1" style="cursor:pointer" width="7%">对方工程师</td>
						<td  class="td1" style="cursor:pointer" width="10%">地址</td>
						<td  class="td1" width="10%">文档</td>
						<td  class="td1" width="10%">其他操作</td>
					</tr>
				</thead>
				<tbody>
				
				<%
					List<ProjectServices> list = new ArrayList<ProjectServices>();
					List<ProjectServices> ppslist = (List<ProjectServices>)request.getAttribute("PprojectServicesList");
					if(ppslist == null){
						list = (List<ProjectServices>)request.getSession().getAttribute("projectServicesList");
					} else {
						list = ppslist;
					}
					for(ProjectServices ps : list){
					%>
					<tr onMouseOver= "this.bgColor   =   '#cccccc '; "   onMouseOut= "this.bgColor   =   '#FFFFFF'; " >  
			       		<td title="<%=ps.getServiceName() %>" align="center" class="td2 txbtip" ><%=ps.getServiceName() %></td>
			       		<td title="<%=ps.getSupportDate() %>" align="center" class="td2 txbtip" ><%=ps.getSupportDate() %></td>
			       		<td title="<%=ps.getServiceType() %>" align="center" class="td2 txbtip" ><%=ps.getServiceType() %></td>
			       		<td title="<%=ps.getOurPeople() %>" align="center" class="td2 txbtip" ><%=ps.getOurPeople() %></td>
			       		<td title="<%=ps.getOtherPeople() %>" align="center" class="td2 txbtip" ><%=ps.getOtherPeople() %></td>
			       		<td title="<%=ps.getAddress() %>" align="center" class="td2 txbtip" ><%=ps.getAddress() %></td>
			       		<td align="left" class="td2 txbtip">
			       			<% if(ps.getDocList().size()>0){ 
			       				for(Doc d : ps.getDocList()){%>
			       				<a href="downDoc.action?docid=<%=d.getId() %>" class='buttonlink txbtip' style="display:inline" title='下载文档' >
			       					<%  String extName = d.getDocName().substring(d.getDocName().lastIndexOf(".")+1);
			       						if("xls".equals(extName) || "xlsx".equals(extName)){ %>
			       						<img width='16' height='16' src='${pageContext.request.contextPath}/images/common/excel.png'/>
			       					<%	}else if("doc".equals(extName) || "docx".equals(extName)){ %>
			       						<img width='16' height='16' src='${pageContext.request.contextPath}/images/common/word.png'/>
			       					<%	}else{ %>
			       						<img width='16' height='16' src='${pageContext.request.contextPath}/images/common/down.png'/>
			       					<%	} %>
			       				</a>
			       				<%=d.getDocName() %><br/>
			       			<%}}else{ %>
			       			<%} %>
					    </td>
			       		<td align="center" class="td2 txbtip">
						     <a href="#" class='buttonlink txbtip' title='修改' onclick="editProjectService(<%=ps.getId()%>)"><img width='16' height='16' src='${pageContext.request.contextPath}/images/common/edit.png'/></a>
						     <img width='16' height='16' src='${pageContext.request.contextPath}/images/common/elbow-line.gif'/>
				       		 <a href="#" class='buttonlink txbtip' title='删除' onclick="delProjectServices('<%=ps.getId()%>','删除此记录会级联删除文档和服务记录内容，你确定要删除吗？')" ><img width='16' height='16' src='${pageContext.request.contextPath}/images/common/delete.png'/></a>
					    </td>
					</tr>	
				  <%}%>	
				</tbody>
			</table>
		</div>
   	<script type="text/javascript">
   	
   		Uploader={
			UPLOAD_IMAGE : "IMAGE",
			UPLOAD_LICENSE : "LICENSE",
			UPLOAD_WAV : "WAV",
			UPLOAD_DOC : "DOC",
			UPLOAD_TAR : "TAR",
			action:'',
			type:'', // icon or bg
			target:'',
			allowImageExt : ".jpg|.jpeg|.gif|.bmp|.png|",
			allowDocExt : "*",
			allowTarExt : ".tar|.tar.gz|",
			allowLicenseExt : ".txt|",
			allowWavExt : ".wav|",
			checkOkHint: '',
			checkFailedHint: '',
			init: function(action, target, type) {
				if(action) {
					this.action = action;
				} else {
					this.action = "/upload_upload.action";
				}
				if(type) {
					this.type = type;
				} else {
					this.type = '';
				}
				if(target) {
					this.target = target;
				} else {
					this.target = '';
				}
			},
			checkBefore : function(checkType){
				var fileName = $('file').value;
				var startUploadEl = $('start_upload');
				if(fileName=='') return false;
				startUploadEl.disabled=true;
				var allowFileExt = '';
				var fileNameExt = fileName.substr(fileName.lastIndexOf(".")).toLowerCase();
				if( this.allowImageExt!=0) {
					if(checkType == this.UPLOAD_IMAGE) {
						allowFileExt = this.allowImageExt;
					} else if(checkType == this.UPLOAD_WAV) {
						allowFileExt = this.allowWavExt;
					} else if(checkType == this.UPLOAD_LICENSE ) {
						allowFileExt = this.allowLicenseExt;
					} else if(checkType == this.UPLOAD_DOC ) {
						allowFileExt = this.allowDocExt;
					} else if(checkType == this.UPLOAD_TAR ) {
						allowFileExt = this.allowTarExt;
					}
				}
				if(allowFileExt!="*" && allowFileExt.indexOf(fileNameExt+"|")==-1) {
					allowFileExt = allowFileExt.replace(/\|$/,"");
					allowFileExt = allowFileExt.replace(/\|/g,", ");
					$('hint').style.display = "block";
					$('hint').innerHTML = "<font color=red>"+this.checkFailedHint.replace("${0}",allowFileExt)+fileNameExt+"</font>";
					return false;
				} else {
					$('hint').innerHTML = this.checkOkHint;
					startUploadEl.disabled = false;
				}
			}
		} 
   		
   	
   		function checkBeforeOfUploadOrImport(file,fileName,type,DIVID,file2){
			if(file2 == undefined){
				file2 = '';
			}
			var fvalue = document.getElementsByName(fileName);
			var psNames = document.getElementsByName("fileNameByHand");
			for(var i = 0; i < fvalue.length; i++){
				var fff = fvalue[i].value;
				var result = fff.substring(fff.lastIndexOf("\\")+1,fff.length);
				psNames[i].value = result;
				//alert(result);
					//psNames[i].value = result[j];
			}
			//alert(psNames.length);
			
			var fileName = document.getElementById(file).value;
			var typeOfFile = fileName.substr(fileName.lastIndexOf(".")).toLowerCase();
			if(type == 'application'){
				if(typeOfFile == '.doc' || typeOfFile == '.docx' || typeOfFile == '.ppt' || typeOfFile == '.xls' || typeOfFile == '.xlsx'){
					if(file2 != ''){
						var fileName2 = document.getElementById(file2).value;
						if(fileName2 != ''){
							var typeOfFile2 = fileName2.substr(fileName2.lastIndexOf(".")).toLowerCase();
							if(typeOfFile2 == '.jpg' || typeOfFile2 == '.gif' || typeOfFile2 == '.bmp' || typeOfFile2 == '.png' || typeOfFile2 == '.jpeg'){
								$(DIVID).style.display = 'none';
							}else{
								$(DIVID).style.display = 'block';
								$(DIVID).innerHTML = "<font color=red>"+Uploader.checkFailedHint.replace("${0}",".doc ,.docx ,.ppt ,.xls ,.xlsx")+typeOfFile2+"</font>";
							}
						}
					}
				}else{
					$(DIVID).style.display = 'block';
					$(DIVID).innerHTML = "<font color=red>"+Uploader.checkFailedHint.replace("${0}",".doc ,.docx ,.ppt ,.xls ,.xlsx")+typeOfFile+"</font>";
				}
			}else if(type == '.txt'){
				if(typeOfFile == '.txt'){
					$(DIVID).style.display = 'none';
				}else{
					$(DIVID).style.display = 'block';
					$(DIVID).innerHTML = "<font color=red>"+Uploader.checkFailedHint.replace("${0}",".txt")+typeOfFile+"</font>";
				}
			}
		};
   		
   		//弹框查看相关产品及Demo信息
   		function lookProductDemoMsg(pid){
   			AjaxUtil.request({
				url : 'lookProductDemoMsg.action',
				params : {pid:pid},
				success : function(responseText){
   					PigossMsg.show("${pageContext.request.contextPath}/jsp/demo/showProductDemoMsg.jsp","查看相关产品及Demo信息",480,400,"");
				},
				failure : function(){
				}
			});
   			
   		};
   		
   		//弹出删除框
   		function delProjectServices(psid,msg){
   			PigossMsg.confirm(msg,null,function yesHandler(){delPSs(psid)},function noHandler(){});
   		};
   		
   		//删除服务记录表
   		function delPSs(psid){
   			AjaxUtil.request({
				url : 'delete_projectServices.action',
				params : {psid:psid},
				success : function(responseText){
					refreshProjects();
				},
				failure : function(){
				}
			});
   		};
   		
   		
   	
   		//读取文件的文件名，放在他下的文本框中
   		function mymethods(filename){
   			var result = filename.substring(filename.lastIndexOf("\\")+1,filename.length);
			document.getElementById("projectServicesName").value = result;
		}
   	
   		//刷新
   		function refreshProjects(){
   			document.getElementById("queryProjectServiceByCondition").submit();
   		};
   		
   		//编辑ProjectServices
   		function editProjectService(psid){
   			AjaxUtil.request({
				url : 'select_editProjectServices.action',
				params : {psid:psid},
				success : function(responseText){
					PigossMsg.show("${pageContext.request.contextPath}/jsp/project/editProjectServices.jsp?id="+psid,"修改服务记录表",460,400,"AddProjectSale.updateProjectServices()");
				},
				failure : function(){
				}
			});
   		};
   		
   	
   		//查询所有工作记录
   		function findAllWorkNote(pid){
   			AjaxUtil.request({
				url : 'find_all_workNote.action',
				params : {pid:pid},
				success : function(responseText){
					PigossMsg.show("${pageContext.request.contextPath}/jsp/project/showProjectServices.jsp?id="+pid,"所有工作记录",500,500,"");
				},
				failure : function(){
				}
			});
   		};
   	
  		//切换项目下的技术备忘录
		function lookTechNote(projectTechNoteId){
			AjaxUtil.request({
				url : 'look_project_techNote.action',
				params : {projectTechNoteId:projectTechNoteId},
				success : function(responseText){
					window.parent.document.getElementById("mainFrame").src="${pageContext.request.contextPath}/jsp/project/project_techNote.jsp?id="+projectTechNoteId;
				},
				failure : function(){
				}
			});
  		};
   		
   		//切换项目下的客户信息表
   		function lookClient(projectClientId){
   			AjaxUtil.request({
				url : 'look_project_client.action',
				params : {projectClientId:projectClientId},
				success : function(responseText){
   					window.parent.document.getElementById("mainFrame").src="${pageContext.request.contextPath}/jsp/project/project_clients.jsp?id="+projectClientId;
				},
				failure : function(){
				}
			});
   		};
   		
   		//切换项目下的文档列表
   		function lookDoc(id){
   			AjaxUtil.request({
				url : 'look_project_doc.action',
				params : {id:id},
				success : function(responseText){
   					window.parent.document.getElementById("mainFrame").src="${pageContext.request.contextPath}/jsp/project/project_doc.jsp?id="+id;
				},
				failure : function(){
				}
			});
   		};
   		
   		//添加服务记录表
   		function addSale(id){
   			var btnHTML = "<a href=\"javascript:AddProjectSale.saveSale();\" class='buttonlink txbtip' title='添加'><img width='16' height='16' src='${pageContext.request.contextPath}/images/common/save.gif'/><p>添加</p><a href=\"javascript:saveSaleAndSaveDoc();\" class='buttonlink txbtip' title='添加后并上传附件'><img width='16' height='16' src='${pageContext.request.contextPath}/images/common/save.gif'/><p>添加并上传附件</p></a><img src='${pageContext.request.contextPath}/images/common/shux.gif' class='split'/>";
			AjaxUtil.request({
				url : 'show_sale.action',
				params : {id:id},
				success : function(responseText){
   					PigossMsg.showWin("${pageContext.request.contextPath}/jsp/project/addSale.jsp?id="+id,"添加服务记录表",550,500,btnHTML);
				},
				failure : function(){
				}
			});
   		};
   		
   		function xxxxxxxx(){
   		
   			//对关联产品的操作
			var showProductMsgInput = document.getElementById("showProductMsgInput");
			//勾选显示产品信息才对产品表进行修改操作
			if(showProductMsgInput.checked){
				var PSproduct = document.getElementById("PSproduct").value;
				var PSproductIp = document.getElementById("PSproductIp").value;
				var noProduct = document.getElementById("noProduct").value;
				//勾选了但没有产品，就不做处理
				if(noProduct == ""){
					//不做处理
				} else {
					//勾选了有产品，才做处理
					var PSproductId = document.getElementById("PSproductId").value;
					var PSproduct = document.getElementById("PSproduct").value;
					var PSproductIp = document.getElementById("PSproductIp").value;
					var PSproductDNS = document.getElementById("PSproductDNS").value;
					var PSproductGetway = document.getElementById("PSproductGetway").value;
					
					if(PSproduct == '' || PSproduct == 0){
						PigossMsg.alert("产品型号不能为空或者空格！");
						return;
					}
					if(PSproductIp == '' || PSproductIp == 0){
						PigossMsg.alert("产品IP不能为空或者空格！");
						return;
					}
					if(PSproductDNS == '' || PSproductDNS == 0){
						PigossMsg.alert("DNS不能为空或者空格！");
						return;
					}
					if(PSproductGetway == '' || PSproductGetway == 0){
						PigossMsg.alert("网关不能为空或者空格！");
						return;
					}
					AjaxUtil.request({
						url : 'update_ps_product.action',
						params : {id:PSproductId,product:PSproduct,ip:PSproductIp,dns:PSproductDNS,gateway:PSproductGetway},
						success : function(responseText){
							//window.location.reload();
						},
						failure : function(){
							PigossMsg.alert("删除失败!");
						}
					});
				}
			}
   		
   		};
   		
   		
   		
   		//--------保存并上传文档------
   		function saveSaleAndSaveDoc(){
   			var id = document.getElementById("pid").value;
		
			var supportDate = document.getElementById("supportDate").value;
			var hours = document.getElementById("hours").value;
			var address = document.getElementById("address").value;
			var otherPeople = document.getElementById("otherPeople").value;
			var serviceType = document.getElementById("serviceType").value;
			var serviceNo = document.getElementById("selectServiceType").value;
			
			//勾选添加工时和联系人操作
			var intoClientContact = document.getElementById("intoClientContact");
			var intoLabor = document.getElementById("intoLabor");
			var insertClientContact = "";
			var insertLabor = "";
			
			if(intoClientContact.checked){
				insertClientContact += intoClientContact.value;
			};
			if(intoLabor.checked){
				insertLabor += intoLabor.value;
			};
			
			//操作ourPeople
			var ourPeople = document.getElementsByName("ourPeople");
			var ourPeoples=''; 
			for(var i=0; i<ourPeople.length; i++){    
				if(ourPeople[i].checked){
					ourPeoples+=ourPeople[i].value+',';
				};
			};    
			//对关联产品的操作
			xxxxxxxx();
			
			
			var i1 = "";
			var i2 = "";
			var i3 = "";
			var i4 = "";
			var i5 = "";
			var i6 = "";
			var i7 = "";
			var i8 = "";
			var i9 = "";
			var i10 = "";
			var i11 = "";
			var i12 = "";
			var i13 = "";
			var i14 = "";
			var i15 = "";
			
			if(hours == '' || hours == 0){
				PigossMsg.alert("小时数不能为空或者空格！");
				return;
			}
			if(otherPeople == '' || otherPeople == 0){
				PigossMsg.alert("他方人员不能为空或者空格！");
				return;
			}
			
			//服务类型的非空验证
			if(serviceNo == ""){
				PigossMsg.alert("服务记录类型必选！");
				return;
			};
			
			//验证现场售后服务
			if(serviceNo=="s1"){
				 i1 = document.getElementById("i1").value;
				 i2 = document.getElementById("i2").value;
				 i3 = document.getElementById("i3").value;
				 i4 = document.getElementById("i4").value;
				 i6 = document.getElementById("i6").value;
				 i7 = document.getElementById("i7").value;
				 i8 = document.getElementById("i8").value;
				 //i13 = document.getElementById("i13").value;
				 
				  if(i1 == '' || i1 == 0){
					  PigossMsg.alert("预期目标不能为空或者空格！");
					  return;
				  }
				  
				  if(i2 == '' || i2 == 0){
					  PigossMsg.alert("工作内容记录不能为空或者空格！");
					  return;
				  }
				  if(i3 == '' || i3 == 0){
					  PigossMsg.alert("客户关注点不能为空或者空格！");
					  return;
				  }
				  if(i4 == '' || i4 == 0){
					  PigossMsg.alert("下一步计划不能为空或者空格！");
					  return;
				  }
				  if(i6 == '' || i6 == 0){
					  PigossMsg.alert("遗留问题不能为空或者空格！");
					  return;
				  }
				  	 
			}
			//对现场实施服务验证
			if(serviceNo=="s2"){
				 i1 = document.getElementById("i1").value;
				 i2 = document.getElementById("i2").value;
				 i3 = document.getElementById("i3").value;
				 i4 = document.getElementById("i4").value;
				 i6 = document.getElementById("i6").value;
				 i7 = document.getElementById("i7").value;
				 i8 = document.getElementById("i8").value;
				 //i13 = document.getElementById("i13").value;
				  if(i1 == '' || i1 == 0){
					  PigossMsg.alert("预期目标不能为空或者空格！");
					  return;
				  }
				  
				  if(i2 == '' || i2 == 0){
					  PigossMsg.alert("工作内容记录不能为空或者空格！");
					  return;
				  }
				  if(i3 == '' || i3 == 0){
					  PigossMsg.alert("客户关注点不能为空或者空格！");
					  return;
				  }
				  if(i4 == '' || i4 == 0){
					  PigossMsg.alert("下一步计划不能为空或者空格！");
					  return;
				  }
				  if(i6 == '' || i6 == 0){
					  PigossMsg.alert("遗留问题不能为空或者空格！");
					  return;
				  }
				  	 
			}
			//对现场售前测试(POC)进行验证
			if(serviceNo=="s3"){
				 i1 = document.getElementById("i1").value;
				 i2 = document.getElementById("i2").value;
				 i3 = document.getElementById("i3").value;
				 i4 = document.getElementById("i4").value;
				 i6 = document.getElementById("i6").value;
				 i7 = document.getElementById("i7").value;
				 i8 = document.getElementById("i8").value;
				 i9 = document.getElementById("i9").value;
				 i11 = document.getElementById("i11").value;
				 //i13 = document.getElementById("i13").value;
				 i15 = document.getElementById("i15").value;
				  if(i1 == '' || i1 == 0){
					  PigossMsg.alert("预期目标不能为空或者空格！");
					  return;
				  }
				  if(i2 == '' || i2 == 0){
					  PigossMsg.alert("工作内容记录不能为空或者空格！");
					  return;
				  }
				  if(i3 == '' || i3 == 0){
					  PigossMsg.alert("客户关注点不能为空或者空格！");
					  return;
				  }
				  if(i4 == '' || i4 == 0){
					  PigossMsg.alert("下一步计划不能为空或者空格！");
					  return;
				  }
				  if(i6 == '' || i6 == 0){
					  PigossMsg.alert("遗留问题不能为空或者空格！");
					  return;
				  }
				  	 
			}
			//对系统升级服务
			/* if(serviceNo=="s4"){
				 i1 = document.getElementById("i1").value;
				 i2 = document.getElementById("i2").value;
				 i3 = document.getElementById("i3").value;
				 i4 = document.getElementById("i4").value;
				 i6 = document.getElementById("i6").value;
				 i7 = document.getElementById("i7").value;
				 i8 = document.getElementById("i8").value;
				 i12 = document.getElementById("i12").value;
				 i13 = document.getElementById("i13").value;
				  if(i1 == '' || i1 == 0){
					  PigossMsg.alert("预期目标不能为空或者空格！");
					  return;
				  }
				  if(i2 == '' || i2 == 0){
					  PigossMsg.alert("工作内容记录不能为空或者空格！");
					  return;
				  }
				  if(i3 == '' || i3 == 0){
					  PigossMsg.alert("客户关注点不能为空或者空格！");
					  return;
				  }
				  if(i4 == '' || i4 == 0){
					  PigossMsg.alert("下一步计划不能为空或者空格！");
					  return;
				  }
				  if(i6 == '' || i6 == 0){
					  PigossMsg.alert("遗留问题不能为空或者空格！");
					  return;
				  }
				  	 
			} */
			//对售前交流验证
			if(serviceNo=="s5"){
				 i1 = document.getElementById("i1").value;
				 i3 = document.getElementById("i3").value;
				 i4 = document.getElementById("i4").value;
				 i5 = document.getElementById("i5").value;
				 i7 = document.getElementById("i7").value;
				 i8 = document.getElementById("i8").value;
				 i9 = document.getElementById("i9").value;
				 i11 = document.getElementById("i11").value;
				 i15 = document.getElementById("i15").value;
				  if(i1 == '' || i1 == 0){
					  PigossMsg.alert("预期目标不能为空或者空格！");
					  return;
				  }
				  if(i9 == '' || i9 == 0){
					  PigossMsg.alert("客户环境调查不能为空或者空格！");
					  return;
				  }
				  if(i3 == '' || i3 == 0){
					  PigossMsg.alert("客户关注点不能为空或者空格！");
					  return;
				  }
				  if(i4 == '' || i4 == 0){
					  PigossMsg.alert("下一步计划不能为空或者空格！");
					  return;
				  }
				  if(i5 == '' || i5 == 0){
					  PigossMsg.alert("交流信息纪要不能为空或者空格！");
					  return;
				  }
				  if(i11 == '' || i11 == 0){
					  PigossMsg.alert("竞争对手动态不能为空或者空格！");
					  return;
				  }
				  	 
			}
			//对会议纪要
			if(serviceNo=="s6"){
				 i1 = document.getElementById("i1").value;
				 i4 = document.getElementById("i4").value;
				 i5 = document.getElementById("i5").value;
				 i6 = document.getElementById("i6").value;
				 i8 = document.getElementById("i8").value;
				  if(i1 == '' || i1 == 0){
					  PigossMsg.alert("预期目标不能为空或者空格！");
					  return;
				  }
				  if(i4 == '' || i4 == 0){
					  PigossMsg.alert("下一步计划不能为空或者空格！");
					  return;
				  }
				  if(i5 == '' || i5 == 0){
					  PigossMsg.alert("交流信息纪要不能为空或者空格！");
					  return;
				  }
				  	 
			}
			//对文档编写
			if(serviceNo=="s7"){
				 i8 = document.getElementById("i8").value;
				 i10 = document.getElementById("i10").value;
				 i14 = document.getElementById("i14").value;
				  if(i10 == '' || i10 == 0){
					  PigossMsg.alert("文档说明不能为空或者空格！");
					  return;
				  }
				  if(i14 == '' || i14 == 0){
					  PigossMsg.alert("对方接收人不能为空或者空格！");
					  return;
				  }
					 
			}
			//对客户拜访
			if(serviceNo=="s8"){
				 i1 = document.getElementById("i1").value;
				 i4 = document.getElementById("i4").value;
				 i5 = document.getElementById("i5").value;
				 i8 = document.getElementById("i8").value;
				  if(i1 == '' || i1 == 0){
					  PigossMsg.alert("预期目标不能为空或者空格！");
					  return;
				  }
				  if(i5 == '' || i5 == 0){
					  PigossMsg.alert("交流信息纪要不能为空或者空格！");
					  return;
				  }
			}
			
			var butHTML = "<a href=\"javascript:saveProjectServicesDoc();\" class='buttonlink txbtip' title='保存'><img width='16' height='16' src='${pageContext.request.contextPath}/images/common/save.gif'/><p>保存</p></a><img src='${pageContext.request.contextPath}/images/common/shux.gif' class='split'/><a href=\"javascript:moreDoc();\" class='buttonlink txbtip' title='更多文档'><img width='16' height='16' src='${pageContext.request.contextPath}/images/common/add.gif'/><p>更多文档</p></a>";
			
			AjaxUtil.request({
				url : 'add_project_sale.action',
				params : {insertClientContact:insertClientContact,insertLabor:insertLabor,supportDate:supportDate,hours:hours,address:address,otherPeople:otherPeople,serviceType:serviceType,ourPeoples:ourPeoples,serviceNo:serviceNo,
					id:id,i1:i1,i2:i2,i3:i3,i4:i4,i5:i5,i6:i6,i7:i7,i8:i8,i9:i9,i10:i10,i11:i11,i12:i12,i13:i13,i14:i14,i15:i15},
				success : function(responseText){
					//PigossMsg.alert("添加成功!");
					//RefreshhProject.refresh();
					PigossMsg.showWin("${pageContext.request.contextPath}/jsp/doc/addProjectServicesDoc.jsp","添加服务记录的文档",400,300,butHTML);
				},
				failure : function(){
					PigossMsg.alert("添加失败!");
				}
			});
			imgCloseShow();
   		}
   		 
   		//删除一个文档框
   		function deleteDocDiv(obj){
   			var idiv = $('projectServicesUploadDoc');
   			var objs = idiv.getElementsByTagName('div');
   			var d = obj.parentElement.parentElement.parentElement.parentElement.parentElement;
   			if(objs.length < 2){
   				PigossMsg.alert("至少上传一个文档！");
   				return;
   			}else{
   				d.parentElement.removeChild(d);
   			};
   		};
   		 
		//增加更多文档
		function moreDoc(){
			var iform = $('projectServicesUploadDoc');
			var d = document.createElement('div');
			var objs = iform.getElementsByTagName('div');
			if(objs.length > 0){
				d.innerHTML = objs[objs.length-1].innerHTML;
			}
			iform.appendChild(d);
		};
   		 
   		 //接受返回值，并做判断
		function uploadfileSuccess(obj){
			
			if(obj == 1){
				refreshProjects();
				imgCloseShow();
			} else {
				PigossMsg.alert('上传失败!');
			}
		};
   		 
   		//操作projectService下的文档上传
   		function saveProjectServicesDoc(){
   			
   			var docProjectServicesId = document.getElementById("docProjectServicesId").value;
   			var docProjectId = document.getElementById("docProjectId").value;
   			var projectServicesName = document.getElementById("projectServicesName").value;
   			var projectServicesDoc = document.getElementById("projectServicesDoc").value;
   			
   			var hiddenImage = document.getElementById("hiddenImage");
   			hiddenImage.style.display = 'block';
   			
   			var isExistSmall = checkDoc(projectServicesDoc);
   			var canUpload = true;
   			//alert(docProjectServicesId +":"+ docProjectId +":"+ projectServicesName +":"+ projectServicesDoc);
   			
   			if(projectServicesDoc == ''){
				PigossMsg.alert('请选择一个文档!');
				canUpload = false;
			}
			if(!isExistSmall){
				PigossMsg.alert('上传文档的类型不符合上传的规则！');
				canUpload = false;
			}
			if(canUpload){
				document.charset='utf-8';
				document.getElementById("projectServicesUploadDoc").submit();
				//PigossMsg.alert("上传成功！");
				//refreshProjects();
				//imgCloseShow();
				
			};
			
   		};
   		//检查文档格式是否合法
		function checkDoc(file){
			var isImage = false;
			var type = file.substr(file.lastIndexOf(".")).toLowerCase();
			if(type == '.doc' || type == '.docx' || type == '.xls' || type == '.xlsx' || type == '.ppt' || type == '.pptx' || type == '.pdf'){
				isImage = true;
			}
			return isImage;
		};
   		
   		//添加技术备忘录
   		function addTechNote(id){
   			PigossMsg.show("${pageContext.request.contextPath}/jsp/project/addTechNote.jsp?id="+id,"添加项目下的技术备忘录",560,510,"AddProjectTechNote.saveTechNote()");
   		};
   		
   		//点击查询技术备忘录
   		function selectTechNote(id){
   			AjaxUtil.request({
				url : 'selectTechNote.action',
				params : {id:id},
				success : function(responseText){
					window.document.getElementById("changePage").src="${pageContext.request.contextPath}/jsp/project/project_techNote.jsp?id="+id;
				},
				failure : function(){
					PigossMsg.alert("查询技术备忘录失败！");
				}
			});
   		};
   		
   		//切换查询条件
   		function notHiddenDiv(){
	        var idDiv = document.getElementById('queryProjectService');
	        if(idDiv.style.display=='none'){
	            idDiv.style.display='block'; 
	        }else{
	           idDiv.style.display='none'; 
	        };
	    };
	    
	    //定义一个map集合，初始化map_,给map_对象增加方法，使map_像Map
		function getMap() {    
		     var map_ = new Object();    
		     map_.put = function(key, value) {    
		         map_[key+'_'] = value;    
		     };    
		     map_.get = function(key) {    
		         return map_[key+'_'];    
		     };    
		     map_.remove = function(key) {    
		         delete map_[key+'_'];    
		     };    
		     map_.keyset = function() {    
		         var ret = "";    
		         for(var p in map_) {    
		             if(typeof p == 'string' && p.substring(p.length-1) == "_") {    
		                 ret += ",";    
		                 ret += p.substring(0,p.length-1);    
		             };    
		         }    
		         if(ret == "") {    
		             return ret.split(",");    
		         } else {    
		             return ret.substring(1).split(",");    
		         };   
		     };    
		     return map_;    
		}
		//把信息表的类型写出来
		var map = getMap();  
		map.put("i1", "预期目标");
		map.put("i2", "工作内容记录");
		map.put("i3", "客户关注点");
		map.put("i4", "下一步计划");
		map.put("i5", "交流信息纪要");
		map.put("i6", "遗留问题");
		map.put("i7", "看法和建议");
		map.put("i8", "其他备注");
		map.put("i9", "客户环境调查");
		map.put("i10", "文档说明");
		map.put("i11", "竞争对手动态");
		map.put("i12", "修改升级后的产品信息");
		map.put("i13", "关联显示产品信息");
		map.put("i14", "对方接收人");
		map.put("i15", "预算及时间预期");
	    
	    
	    //勾选显示产品信息的操作
	    function checkedShowPDMsg(){
	    	var showPDMsg = document.getElementById("showPDMsg");
	    	var showProductMsgInput = document.getElementById("showProductMsgInput");
	    	
	    	if(showProductMsgInput.checked){
		 		showPDMsg.style.display='block';
		 	}else{
		 		showPDMsg.style.display='none';
		 	};
	    };
	    
	    //勾选显示demo信息的操作
	    function checkedShowDemoMsg(pid){
	    	var showDemoContent = document.getElementById("showDemoContent");
	    	var showDemoMsgInput = document.getElementById("showDemoMsgInput");
	    	if(showDemoMsgInput.checked){
	    		/* AjaxUtil.request({
					url : 'findDemoByPid.action',
					params : {pid:pid},
					success : function(responseText){
					},
					failure : function(){
						PigossMsg.alert("查询技术备忘录失败！");
					}
				}); */
		 				showDemoContent.style.display='block';
		 	}else{
		 		showDemoContent.style.display='none';
		 	};
	    };
	    
		//点击服务记录表类型时，根据后台定义的记录信息表排序并进行展现
		 function onChangeService() {
			 var serNo = document.getElementById("selectServiceType").value;
			 
			 //操作显示关联产品的信息
			 var showProductMsg = document.getElementById("showProductMsg");
			 var showDemoMsg = document.getElementById("showDemoMsg");
			 var showProductMsgInput = document.getElementById("showProductMsgInput");
			 
			 if("s1" == serNo || "s2" == serNo){
			 	showProductMsg.style.display = 'inline';
			 } else {
			 	showProductMsg.style.display = 'none';
			 };
			 if("s3" == serNo){
			 	showDemoMsg.style.display = 'inline';
			 } else {
			 	showDemoMsg.style.display = 'none';
			 };
			 
			 AjaxUtil.request({
				url : 'selectServiceTypeToShowDiv.action',
				params : {serNo:serNo},
				success : function(xmlHttp){
					var json = eval("("+xmlHttp+")");
					var table = document.getElementById("addServiceTable");
					table.deleteTFoot();
					for(var i = 0; i < json.length; i++){
						//在这里进行展现所要呈现的div
						var table = document.getElementById("addServiceTable");
						var tfoot = table.createTFoot();
						tfoot.id="showDiv";
						var tr0 = tfoot.insertRow();
						tr0.name="select";
						var td0 = tr0.insertCell();
						td0.align = "right";
						td0.innerHTML=map.get(json[i])+"：";
						var td1 = tr0.insertCell();
						var addEvent = document.createElement("<textarea  rows='3' cols='44' name='"+map.get(json[i])+"' id='"+json[i]+"'></textarea>");
						td1.appendChild(addEvent);
					};
				},
				failure : function(){
					PigossMsg.alert("获取列表失败！");
				}
			});
			
		};
		
		initTableWidget('dArticleList',['S','S',"S",'S','S','S','S',false]);
	</script>
   
   
  </body>
</html>
